package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.SalarysTructureDao;
import com.woniu.humanresource.entity.*;
import com.woniu.humanresource.service.SalarysTructureService;
import org.apache.poi.ss.formula.functions.Count;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SalarysTructureServiceImpl implements SalarysTructureService {
    @Resource
    SalarysTructureDao salarysTructureDao;


    @Override
    public void insertSalarysTructure(SalarysTructure salarysTructure) {
        salarysTructureDao.insertSalarysTructure(salarysTructure);
    }

    @Override
    public PageBean<SalarysTructure> selectSalarysTructure(SalarysTructure salarysTructure, int pageIndex, int pageSize) {
        //创建用于接收beanlist的对象
        List<SalarysTructure> stlist = salarysTructureDao.selectSalarysTructure(salarysTructure, 1, 10);
        //封装pagebean并赋值
        PageBean<SalarysTructure> pageBean=new PageBean<>();
        pageBean.setBeanList(stlist);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectSalarysTructurecount(salarysTructure));
        return pageBean;
    }

    @Override
    public void deleteSalarysTructure(int id) {
        salarysTructureDao.deleteSalarysTructure(id);
    }

    @Override
    public void updateSalarysTructure(SalarysTructure salarysTructure) {
        salarysTructureDao.updateSalarysTructure(salarysTructure);
    }

    //条数
    @Override
    public int selectSalarysTructurecount(SalarysTructure salarysTructure) {
        int count = salarysTructureDao.selectSalarysTructurecount(salarysTructure);
        return count;
    }
}